﻿<%@ Page Title="Translations &raquo; ResourceBlender" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Translations.aspx.cs" Inherits="Translations" EnableEventValidation="false" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>

<asp:Content ID="contentHead" ContentPlaceHolderID="head" Runat="Server">
    <link rel="Stylesheet" type="text/css" href="css/spreadsheet.css" />
    <!--[if IE]>
    <link rel="Stylesheet" type="text/css" href="css/ie-spreadsheet.css" />
    <![endif]-->
</asp:Content>
<asp:Content ID="contentMain" ContentPlaceHolderID="cntMain" Runat="Server">
    <form id="frmTranslations" runat="server">
        <asp:ScriptManager ID="scrUpdateLanguages" runat="server"></asp:ScriptManager>
        <div style="width: 90%; margin: 0 auto;">
            <asp:MultiView ID="mltMain" runat="server" ActiveViewIndex="0">
                <asp:View ID="viwNoApps" runat="server">
                    <h1><asp:Label ID="lblManageTranslationsHeading" runat="server" Text="Manage Translations"></asp:Label></h1>
                    <p>You must <asp:HyperLink ID="lnkAddApplication" runat="server" Text="add an application" NavigateUrl="~/Applications.aspx">add an application</asp:HyperLink> before generating resources.</p>
                </asp:View>
                <asp:View ID="viwSelectTranslations" runat="server">
                    <h1><asp:Label ID="lblSelectTranslationsHeading" runat="server" Text="Manage Translations"></asp:Label></h1>
                    <fieldset>
                        <legend>Select Components</legend>
                        <asp:UpdatePanel ID="updRadApplication" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div class="componentholder">
                                    <label class="block">Application</label>
                                    <asp:RadioButtonList ID="radApplication" runat="server" RepeatLayout="Flow" 
                                                         onselectedindexchanged="ShowLanguages" 
                                        AutoPostBack="True" CssClass="plain"></asp:RadioButtonList>
                                </div>
                                <div class="componentholder">
                                    <asp:Label ID="lblBundleName" runat="server" Text="Bundle" 
                                        AssociatedControlID="lstBundles" CssClass="block"></asp:Label>
                                    <asp:ListBox ID="lstBundles" runat="server" SelectionMode="Multiple" 
                                                 Rows="10"></asp:ListBox>
                                </div>
                                <div class="componentholder">
                                    <label class="block">Languages</label>
                                    <asp:ListBox ID="lstLanguages" runat="server" SelectionMode="Multiple" 
                                                 Rows="10"></asp:ListBox>
                                    <asp:RequiredFieldValidator ID="vldLanguages" ControlToValidate="lstLanguages" runat="server" ErrorMessage="At least one language must be selected"></asp:RequiredFieldValidator>
                                </div>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="radApplication" 
                                                          EventName="SelectedIndexChanged" />
                            </Triggers>
                        </asp:UpdatePanel>
                        <asp:UpdateProgress ID="prgRadApplication" runat="server" 
                                            AssociatedUpdatePanelID="updRadApplication" 
                                            DisplayAfter="100">
                            <ProgressTemplate>
                                <div class="centered"><asp:Image ID="imgLoadingLanguagesSelection" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading Languages..." /></div>
                            </ProgressTemplate>
                        </asp:UpdateProgress>
                        <div class="clear">&nbsp;</div>
                    </fieldset>
                    <asp:Button ID="btnEditTranslations" runat="server" Text="Edit Translations" 
                        CssClass="uniformbutton" onclick="btnEditTranslations_Click" />
                    <asp:Button ID="btnToExcel" runat="server" Text="Export to XML" 
                        PostBackUrl="Excel.aspx" />
                </asp:View>
                <asp:View ID="viwManageTranslations" runat="server">
                    <asp:SqlDataSource ID="dsMain" runat="server"
                         ConnectionString="<%$ ConnectionStrings:Default %>"
                         ProviderName="<%$ ConnectionStrings:Default.ProviderName %>"
                         >
                         </asp:SqlDataSource>
                    <asp:ObjectDataSource ID="dsBundles" runat="server"></asp:ObjectDataSource>
                    <div id="fullsizeholder" class="ssFullSize" runat="server">
                        <h1><asp:Label ID="lblEditingTranslationsFor" runat="server" Text="formatted text"></asp:Label></h1>
                        <div style="float:left">
                            <asp:UpdateProgress ID="upgGrdTranslations" runat="server" 
                                                AssociatedUpdatePanelID="updGrdTranslations" 
                                                DisplayAfter="100">
                                <ProgressTemplate>
                                    <div class="centered"><asp:Image ID="imgLoadingTranslation" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading..." /></div>
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </div>
                        <div id="inlinenav">
                            <asp:LinkButton ID="lnkExpandScreen" runat="server" CssClass="lnkContract" 
                                OnClientClick="return toggleFullWindow(this);" onclick="lnkExpandScreen_Click">Contract to normal size</asp:LinkButton>
                            <ul>
                                <li><a class="navApplications" id="lnkApplications" href="~/Applications.aspx" runat="server" title="Applications">Applications</a></li>
                                <li><a class="navTranslations" id="lnkTranslations" href="~/Translations.aspx" runat="server" title="Translations">Translations</a></li>
                                <li><a class="navGenerate" id="lnkGenerate" href="~/Generate.aspx" runat="server" title="Generate">Generate</a></li>
                                <li><a class="navImport" id="lnkImport" href="~/Import.aspx" runat="server" title="Import">Import</a></li>
                                <li><a class="navHelp" href="http://wiki.lime49.com/index.php?title=ResourceBlender" title="Help">Help</a></li>
                                <li><a class="navBackup" id="lnkBackup" href="~/Backup.aspx" runat="server" title="Backup &amp; Restore">Backup &amp; Restore</a></li>
                                <li><a class="navSettings" id="lnkSettings" href="~/Settings.aspx" runat="server" title="Settings">Settings</a></li>
                            </ul>
                        </div>
                        <div class="clear"></div>
                        <asp:UpdatePanel ID="updGrdTranslations" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:GridView ID="grdTranslations" runat="server" AllowPaging="True" 
                                    AllowSorting="True" AutoGenerateColumns="true" CssClass="nicetable" 
                                    Width="100%" DataKeyNames="applicationid,bundlename,elementname"
                                    OnRowDatabound="row_DataBound" 
                                    OnRowCommand="grd_RowCommand" 
                                    OnPageIndexChanging="grd_PageIndexChanging"
                                    OnSorting="grd_Sorting"
                                    OnPreRender="grd_PreRender"
                                    PageSize="15">
                                    <PagerSettings PageButtonCount="8" Mode="NumericFirstLast" Position="TopAndBottom" />
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <%# Container.DataItemIndex +1 %>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="ssRowLabel" HorizontalAlign="Center" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Bundle" SortExpression="bundlename">
                                            <ItemTemplate>
                                                <asp:MultiView ID="mltBundle" runat="server" ActiveViewIndex="0">
                                                    <asp:View ID="viwShowBundle" runat="server">
                                                        <asp:Label ID="lblBundleName" runat="server" Text='<%# Eval("bundlename") %>'></asp:Label>
                                                    </asp:View>
                                                    <asp:View ID="viwEditBundle" runat="server">
                                                        <asp:DropDownList ID="cboBundleName"  runat="server"></asp:DropDownList>
                                                    </asp:View>
                                                </asp:MultiView>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="ssCell" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Element" SortExpression="elementname">
                                            <ItemTemplate>
                                                <asp:MultiView ID="mltElement" runat="server" ActiveViewIndex="0">
                                                    <asp:View ID="viwShowElement" runat="server">
                                                        <asp:Label ID="lblElementName" runat="server" Text='<%# Eval("elementname") %>' EnableViewState="False"></asp:Label>
                                                    </asp:View>
                                                    <asp:View ID="viwEditElement" runat="server">
                                                        <asp:Label ID="lblElementNameDesc" runat="server" Text="Element Name" AssociatedControlID="txtElementName" EnableViewState="False"></asp:Label>
                                                        <br />
                                                        <asp:TextBox ID="txtElementName" runat="server" Text='<%# Eval("elementname") %>' EnableViewState="False"></asp:TextBox>
                                                        <br />
                                                        <asp:Label ID="lblElementComment" runat="server" Text="Comment" AssociatedControlID="txtElementComment" EnableViewState="False"></asp:Label>
                                                        <br />
                                                        <asp:TextBox ID="txtElementComment" runat="server" Text='<%# Eval("elementcomment") %>' TextMode="MultiLine" EnableViewState="False"></asp:TextBox>
                                                    </asp:View>
                                                </asp:MultiView>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="ssCell" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Edit">
                                            <ItemTemplate>
                                                <asp:MultiView ID="mltActions" runat="server" ActiveViewIndex="0">
                                                    <asp:View ID="viwEdit" runat="server">
                                                        <div class="centered">
                                                            <asp:ImageButton ID="btnEdit" runat="server" 
                                                                AlternateText='<%# "Edit " + Eval("elementname") %>' EnableViewState="False"
                                                                CommandName="edittranslation" 
                                                                ImageUrl="~/images/edit.png" />
                                                        </div>
                                                    </asp:View>
                                                    <asp:View ID="viwSave" runat="server">
                                                        <asp:Label ID="lblTranslationIdDesc" runat="server" Text="Translation ID" EnableViewState="False" AssociatedControlID="cboTranslationID"></asp:Label>
                                                        <br />
                                                        <asp:DropDownList ID="cboTranslationID" runat="server">
                                                        </asp:DropDownList>
                                                        <asp:Label ID="lblTranslationId" runat="server" Text='<%# Eval("translationid") %>' EnableViewState="False" Visible="false"></asp:Label><%-- used to bind the combobox selected index --%>
                                                        <br />
                                                        <asp:Button ID="btnChangeTranslation"  Visible="false" runat="server" Text="Change Translation" CommandName="changetranslation" EnableViewState="False" />
                                                        <asp:Label ID="lblError" runat="server" Text="" CssClass="error"></asp:Label>
                                                        <asp:Label ID="lblTranslationComment" runat="server" Text="Comment" AssociatedControlID="txtTranslationComment" EnableViewState="False"></asp:Label>
                                                        <br />
                                                        <asp:TextBox ID="txtTranslationComment" runat="server" Text='<%# Eval("translationcomment") %>' TextMode="MultiLine" EnableViewState="False"></asp:TextBox>
                                                        <br />
                                                        <asp:Button ID="btnDeleteElement" runat="server" Text="Delete Element" CommandName="deleteelement" CommandArgument='<%# Eval("id") %>' />
                                                        <asp:Button ID="btnSave" runat="server" Text="Save" CommandName="savetranslation" CommandArgument='<%# Eval("id") %>' />
                                                    </asp:View>
                                                </asp:MultiView>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="ssCell" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <HeaderStyle CssClass="excelHead" />
                                    <RowStyle CssClass="even" />
                                    <AlternatingRowStyle CssClass="alt" />
                                    <PagerStyle CssClass="pager" />
                                    <EmptyDataTemplate>
                                    No translations
                                    </EmptyDataTemplate>
                                </asp:GridView>
                                <div class="niceform">
                                    <fieldset style="background: #ededff;">
                                        <legend>Add Element</legend>
                                        <fieldset>
                                                <legend>Element</legend>
                                                <div class="formrow block">
                                                    <asp:Label ID="lblAddBundleName" runat="server" AssociatedControlID="cboAddBundleName" 
                                                        Text="Bundle Name"></asp:Label>
                                                    <asp:DropDownList ID="cboAddBundleName" runat="server">
                                                    </asp:DropDownList>
                                                </div>
                                                <div class="formrow block">
                                                    <asp:Label ID="lblAddElementName" runat="server" AssociatedControlID="txtAddElementName"
                                                        Text="Element Name"></asp:Label>
                                                    <asp:TextBox ID="txtAddElementName" runat="server" EnableViewState="false"></asp:TextBox>
                                                    <asp:Label ID="lblAddError" runat="server" CssClass="error" Visible="false"></asp:Label>
                                                </div>
                                                <div class="formrow block">
                                                    <asp:Label ID="lblAddElementComment" runat="server" Text="Element Comment" ToolTip="Notes about the element's location"  AssociatedControlID="txtAddElementComment" EnableViewState="False"></asp:Label>
                                                    <asp:TextBox ID="txtAddElementComment" runat="server" TextMode="MultiLine"></asp:TextBox>
                                                </div>
                                            </fieldset>
                                        <fieldset>
                                                <legend>Translation</legend>
                                                <div class="formrow block">
                                                    <asp:Label ID="lblAddTranslationID" runat="server" Text="Translation ID" AssociatedControlID="cboAddTranslationID" EnableViewState="False"></asp:Label>
                                                    <asp:DropDownList ID="cboAddTranslationID" runat="server" AutoPostBack="true"
                                                        OnSelectedIndexChanged="ChangeAddDisplayedTranslation">
                                                    </asp:DropDownList>
                                                </div>
                                                <div class="formrow block">
                                                    <asp:Label ID="lblAddTranslationComment" runat="server" Text="Translation Comment" ToolTip="Contextual information about the translation" AssociatedControlID="txtAddTranslationComment" EnableViewState="False"></asp:Label>
                                                    <asp:TextBox ID="txtAddTranslationComment" runat="server" TextMode="MultiLine" EnableViewState="False"></asp:TextBox>
                                                </div>
                                                <asp:Panel ID="pnlDynamicAddTranslation" runat="server" DefaultButton="btnAddElement">
                                                </asp:Panel>
                                                <div class="formrow block">
                                                    <asp:Button ID="btnAddElement" runat="server" Text="Add Element" 
                                                        CssClass="uniformbutton" EnableViewState="False" 
                                                        OnClick="btnAddElement_Click" />
                                                </div>
                                            </fieldset>
                                    </fieldset>
                                </div><!--add form-->
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div><!--fullsizeholder-->
                </asp:View>
            </asp:MultiView>
        </div><!--90% width-->
    </form>
</asp:Content>

